import CommonUtils from "../../utils/CommonUtils";

const documentsInfo = {
    "documents": [],
    "currentDocument": {
        "id": null,
        "docName": '',
        "docDesc": '',
        "stateId": 1,
        "published": 1,
        "owner": 1,
        "spaceId": 1,
        "orderNo": 1,
        "createTime": null,
        "creator": null,
        "updateTime": null,
        "updater": null
    },
    "currentMenus": [],
    "currentApiInfo": {
        "apiInfo": {
            apiName: '接口标题',
            "apiDesc": "测试",
            "apiUri": "/test",
            "apiHeader": " HTTP/1.1 \nContent-Type: application/json;charset=UTF-8\n",
            "apiType": "GET",
            "enableFlag": 1,
            "serverId": null
        },
        apiParamDescVo: {
            inputHeader: {
                "id": null,
                "paramDesc": "无数据",
                "enableFlag": 1,
                "createTime": "2023-03-30T15:30:25.000+00:00",
                "updateTime": "2023-03-30T15:30:25.000+00:00",
                "paramPath": "",
                "creator": null,
                "updater": null,
                "apiId": 4,
                "paramType": 4,
                "dataType": 1,
                "title": "body参数说明",
                "paramLevel": 1,
                "orderNo": 1,
                "fields": [
                    {
                        "id": -99999,
                        "apiId": null,
                        "fieldName": "",
                        "fieldMust": "否",
                        "fieldDesc": "",
                        "enableFlag": 1,
                        "createTime": "2023-03-24T13:56:28.000+00:00",
                        "updateTime": "2023-03-24T13:56:28.000+00:00",
                        "fieldTypeId": 2,
                        "spaceId": 1,
                        "usePriority": 1,
                        "creator": null,
                        "updater": null,
                        "paramId": null,
                        "orderNo": 1,
                        "paramFieldDesc": "",
                        "fieldDescOut": "",
                        "descMode": 0
                    }
                ]
            }
        },
        currentParamHis: {
            paramName: '',
            paramDesc: '',
            paramInputPathStr: '',
            paramInputHeaderStr: '',
            paramInputQueryStr: '',
            paramInputBodyStr: '',
            paramOutputHeaderStr: '',
            paramOutputBodyStr: '',
        }
    },
    "createFlag": false
}

const docMenu = {
    "menuName": "",
    "apiDesc": "",
    "menuType": 0,
    "apiUri": "",
    "apiType": "GET",
    "id": null,
    "apiId": null,
    "parentId": 1,
    "idPath": "1",
    "enableFlag": 1,
    "desc": "",
    "docId": 0,
    "orderNo": 0,
    "primaryFlag": 0,
    "creator": null,
    "updater": null,
    "apiName": "",
    "children": []
}

const apiMenuTitle = {
    apiInfo: {
        title: "1.接口信息",
        children: {
            desc: '1.1.接口说明',
            uri: '1.1.接口信息',
            header: '1.2.服务信息'
        }
    },
    paramFieldDesc: {
        title: "2.参数&字段说明",
        children: {
            input: "2.1.入参参数",
            output: "2.2.返回参数"
        }
    },
    paramHis: {
        title: "3.接口参数示例",
        children: {
            input: "3.1入参参数",
            output: "3.2返回参数"
        },
        childrenTitles: {
            paramInputPathStr: '入参路径参数',
            paramInputHeaderStr: '入参头参数',
            paramInputQueryStr: '入参查询参数',
            paramInputBodyStr: '入参body参数',
            paramOutputHeaderStr: '返回头参数',
            paramOutputBodyStr: '返回body'
        }
    },
    business: {
        title: "4.业务逻辑"
    }
}

const apiInfo = {
    "id": null,
    "apiName": "占位数据",
    "apiDesc": "查询用户有权限的工作空间接口",
    "apiUri": "/space/getSpace",
    "apiHeader": " HTTP/1.1 \nContent-Type: application/json;charset=UTF-8\n",
    "apiType": "GET",
    "enableFlag": 1,
    "createTime": "2023-03-27T14:31:32.000+00:00",
    "updateTime": "2023-03-27T14:43:55.000+00:00",
    "stateId": 3,
    "serverId": null,
    "spaceId": 1,
    "owner": null,
    "creator": null,
    "updater": null
}

const commonApiInfo = {id: 1, apiName: '通用接口', apiType: '', apiUri: '通用接口'}

const subMenuId = {
    id_1: 'id_1',
    id_1_1: 'id_1_1',
    id_1_2: 'id_1_2',
    id_2: 'id_2',
    id_2_1: 'id_2_1',
    id_2_1_1: 'id_2_1_1',
    id_2_1_2: 'id_2_1_2',
    id_2_1_3: 'id_2_1_3',
    id_2_1_4: 'id_2_1_4',
    id_2_2: 'id_2_2',
    id_2_2_1: 'id_2_2_1',
    id_2_2_2: 'id_2_2_2',
    id_3: 'id_3',
    id_3_1: 'id_3_1',
    id_3_2: 'id_3_2',
    id_4: 'id_4',
}

const subMenuVal = {
    id_1: 1,
    id_1_1: 101000,
    id_1_2: 102000,
    id_2: 2,
    id_2_1: 201000,
    id_2_1_1: 201010,
    id_2_1_2: 201020,
    id_2_1_3: 201030,
    id_2_1_4: 201040,
    id_2_2: 202000,
    id_2_2_1: 202010,
    id_2_2_2: 202020,
    id_3: 3,
    id_3_1: 301000,
    id_3_2: 302000,
    id_4: 4,
    id_1_l: 100000,
    id_2_l: 200000,
    id_3_l: 300000,
    id_4_l: 400000,
    id_5_l: 500000
}

const subMenu = [
    {
        id: subMenuId.id_1, val: subMenuVal.id_1, txt: '1.接口信息', children: [
            {id: subMenuId.id_1_1, val: subMenuVal.id_1_1, txt: '1.1.接口信息', children: []},
            {id: subMenuId.id_1_2, val: subMenuVal.id_1_2, txt: '1.2.服务信息', children: []},
        ]
    },
    {
        id: subMenuId.id_2, val: subMenuVal.id_2, txt: '2.参数&字段说明', children: [
            {id: subMenuId.id_2_1, val: subMenuVal.id_2_1, txt: '2.1.入参参数', children: []},
            {id: subMenuId.id_2_2, val: subMenuVal.id_2_2, txt: '2.2.返回参数', children: []},
        ]
    },
    {
        id: subMenuId.id_3, val: subMenuVal.id_3, txt: '3.接口参数示例', children: [
            {id: subMenuId.id_3_1, val: subMenuVal.id_3_1, txt: '3.1.入参参数', children: []},
            {id: subMenuId.id_3_2, val: subMenuVal.id_3_2, txt: '3.2.返回参数', children: []},
        ]
    },
    {id: subMenuId.id_4, val: subMenuVal.id_4, txt: '4.接口信息', children: []},
]

const subMenuDesc = {
    inputHeader: {id: subMenuId.id_2_1_1, val: subMenuVal.id_2_1_1, txt: '2.1.1.入参请求头参数说明', children: []},
    inputPath: {id: subMenuId.id_2_1_2, val: subMenuVal.id_2_1_2, txt: '2.1.2.入参路径参数说明', children: []},
    inputQuery: {id: subMenuId.id_2_1_3, val: subMenuVal.id_2_1_3, txt: '2.1.3.入参查询参数说明', children: []},
    ib: {id: subMenuId.id_2_1_4, val: subMenuVal.id_2_1_4, txt: '2.1.4.入参体参数说明', children: []},
    oh: {id: subMenuId.id_2_2_1, val: subMenuVal.id_2_2_1, txt: '2.2.1.返回请求头参数说明', children: []},
    ob: {id: subMenuId.id_2_2_1, val: subMenuVal.id_2_2_2, txt: '2.2.2.返回体参数说明', children: []},
}
function getFieldDemo() {
    return documentsInfo.currentApiInfo.apiParamDescVo.inputHeader.fields[0]
}

function getDisplayFlag() {
    let flag = {
        input: {
            inputHeader: false,
            inputPath: false,
            inputQuery: false,
            inputBody: false
        },
        output: {
            outputHeader: false,
            outputBody: false
        },
        inputFlag: false,
        outputFlag: false,
    }
    return CommonUtils.cloneObj(flag)
}

function getSubMenuRef(val) {
    console.log('val', val)
    if (val < subMenuVal.id_1_l) {
        return ''
    } else if (val < subMenuVal.id_2_l) {
        return subMenuId.id_1
    } else if (val < subMenuVal.id_3_l) {
        return subMenuId.id_2
    } else if (val < subMenuVal.id_4_l) {
        return subMenuId.id_3
    } else if (val < subMenuVal.id_5_l) {
        return subMenuId.id_4
    }
    return ''
}

export default {
    documentsInfo, docMenu, apiMenuTitle, getFieldDemo, getDisplayFlag, apiInfo, commonApiInfo,
    subMenuVal, subMenu, subMenuId, getSubMenuRef, subMenuDesc
}